package com.espirit.hr;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;

import com.espirit.eap.annotation.DomainModel;
import com.espirit.eap.sa.Employee;
import com.espirit.finance.core.EntityAccountAware;

@Entity
@DomainModel
public class EmployeeAccount implements Serializable, EntityAccountAware {
	private static final long serialVersionUID = 4244033108062448415L;

	private Integer id;
	
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}	
	
	public Integer getDeliveryTimes() {
		return deliveryTimes;
	}
	public void setDeliveryTimes(Integer deliveryTimes) {
		this.deliveryTimes = deliveryTimes;
	}
	public BigDecimal getLeaveAppHours() {
		return leaveAppHours;
	}
	public void setLeaveAppHours(BigDecimal leaveAppHours) {
		this.leaveAppHours = leaveAppHours;
	}
	
	public BigDecimal getFaultAmount() {
		return faultAmount;
	}
	public void setFaultAmount(BigDecimal faultAmount) {
		this.faultAmount = faultAmount;
	}
	public BigDecimal getOtHours() {
		return otHours;
	}
	public void setOtHours(BigDecimal otHours) {
		this.otHours = otHours;
	}
	
	@ManyToOne
	public Employee getEmployee() {
		return employee;
	}
	public void setEmployee(Employee employee) {
		this.employee = employee;
	}
	

	@OneToMany(targetEntity = EmployeeAccountLateItem.class ,orphanRemoval = true, fetch=FetchType.LAZY,  cascade = CascadeType.ALL, mappedBy = "parent")
	public List<EmployeeAccountLateItem> getLateItems() {
		return lateItems;
	}
	public void setLateItems(List<EmployeeAccountLateItem> lateItems) {
		this.lateItems = lateItems;
	}

	public List<EmployeeAccountLateItem> safeLateItems() {
		if (lateItems == null){
			lateItems = new  ArrayList<EmployeeAccountLateItem>();
		}
		return lateItems;
	}
	

	public Integer getAbsentDays() {
		return absentDays;
	}
	public void setAbsentDays(Integer absentDays) {
		this.absentDays = absentDays;
	}


	@OneToMany(targetEntity = EmployeeAccountLeaveEarlyItem.class ,orphanRemoval = true, fetch=FetchType.LAZY,  cascade = CascadeType.ALL, mappedBy = "parent")
	public List<EmployeeAccountLeaveEarlyItem> getLeaveEarlyItems() {
		return leaveEarlyItems;
	}
	public void setLeaveEarlyItems(List<EmployeeAccountLeaveEarlyItem> leaveEarlyItems) {
		this.leaveEarlyItems = leaveEarlyItems;
	}

	public List<EmployeeAccountLeaveEarlyItem> safeLeaveEarlyItems() {
		if (leaveEarlyItems == null){
			leaveEarlyItems = new  ArrayList<EmployeeAccountLeaveEarlyItem>();
		}
		return leaveEarlyItems;
	}

	private Integer deliveryTimes;
	private BigDecimal leaveAppHours;
	private BigDecimal faultAmount;
	private BigDecimal otHours;
	private Employee employee;
	private List<EmployeeAccountLateItem> lateItems ;
	private List<EmployeeAccountLeaveEarlyItem> leaveEarlyItems;
	private Integer absentDays;


	
}
